Page({

  /**
  * 页面的初始数据
  */
  data: {
    option: '',
    presentCard:'',
    receiverName: '',
    senderName: '',
    senderLogo: '',
    courseLogo: ''
  },

  /**
  * 生命周期函数--监听页面加载
  */
  onLoad: function (options) {
    console.log(options)
    var option = JSON.parse(options.presentPackage);
    var presentCard = JSON.parse(options.presentCard);
    var courseLogo = option.courseLogo; //专辑banner
    var createDate = presentCard.createDate;
    var times = new Date(createDate).format("yyyy-MM-dd");
    var receiverName = presentCard.receiverName; //接收人名字
    var senderName = presentCard.senderName; //发送人名字
    var senderLogo = presentCard.senderLogo; //发送人的头像
    var courseName = option.courseName; // 专辑名称
    console.log(courseName)
    console.log(senderLogo)
    console.log(courseLogo)
    presentCard.times = times;
    console.log(presentCard)
    var price = option.price;
    var prices = price/100;
    option.prices = prices;
    console.log(option)
    this.setData({
      option: option,
      presentCard: presentCard,
      receiverName: receiverName,
      senderName: senderName,
      senderLogo: senderLogo,
      courseLogo: courseLogo,
      courseName: courseName
    })
  },
  
  //跳转礼品卡详情
  checkGiftDetails:function(){
    var receiverName = this.data.receiverName;
    var senderName = this.data.senderName;
    var senderLogo = this.data.senderLogo;
    var courseLogo = this.data.courseLogo;
    var courseName = this.data.courseName;
    wx.redirectTo({
      url: '../checkGifts/checkGifts?&receiverName=' + receiverName + '&senderName=' + senderName + '&senderLogo=' + senderLogo + '&courseLogo=' + courseLogo + '&courseName=' + courseName
    })
  },

  //跳转去观看
  towatch: function (event) {
    var id = event.currentTarget.dataset.id;
    var mediaType = event.currentTarget.dataset.mediaType;
    console.log(id)
    console.log(mediaType)
    if (mediaType == 'AUDIO') {
      wx.navigateTo({
        url: '../audioAlbumDetail/audioAlbumDetail?id=' + id
      })
    } else {
      wx.navigateTo({
        url: '../videoAlbumDetail/videoAlbumDetail?id=' + id
      })
    }
  },
})